package cn.bx.spring.print;

public class TextPaper implements Paper {

    private int wordsLines;//一行几个字

    private int lines;//一页的行数

    public void setWordsLines(int wordsLines) {
        this.wordsLines = wordsLines;
    }

    public void setLines(int lines) {
        this.lines = lines;
    }

    @Override
    public void print(String s) {
        //分页的方式输出
        int line=1;
        int page=1;
        int words=0;
        char []cr=s.toCharArray();
        for(char c:cr){
            System.out.print(c);
            words++;
            if(words>=wordsLines){
                System.out.println();
                line++;
                words=0;
                if(line>=lines){
                    line=0;
                    System.out.println("--"+(page++)+"--");

                }
            }
        }
    }
}
